#ifndef COLOR4F_H_CEDXMB57
#define COLOR4F_H_CEDXMB57

// #include "../cglx.h"

class Color4f {
    
private:
//    GLfloat myColor[4];
    
public:
	GLfloat myColor[4];
    
    /*
     * Initialize color to (0,0,0,1), Alpha channel set to 1 by default
     */
    Color4f () {
        myColor[0] = 0;
        myColor[1] = 0;
        myColor[2] = 0;
        myColor[3] = 1;
    }

    Color4f (GLfloat red, GLfloat green, GLfloat blue) {
        myColor[0] = red;
        myColor[1] = green;
        myColor[2] = blue;
        myColor[3] = 1;
    }
    
    Color4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) {
        myColor[0] = red;
        myColor[1] = green;
        myColor[2] = blue;
        myColor[3] = alpha;
    }
    
    virtual ~Color4f () {
        
    }
    
    GLfloat& operator[](int index) {
        return myColor[index];
    }
    
    GLfloat operator[](int index) const {
    	return myColor[index];
    }
    
    void set(GLfloat r, GLfloat g, GLfloat b, GLfloat a) {
        set(r, g, b);
        myColor[3] = a;
    }
    
    void set(GLfloat r, GLfloat g, GLfloat b) {
        myColor[0] = r;
        myColor[1] = g;
        myColor[2] = b;
    }
    
    void set(const Color4f newColor) {
        for(size_t i = 0; i < 4; ++i)
        {
            myColor[i] = newColor[i];
        }
    }
    
    const GLfloat * getColorsArray() {
        return myColor;
    }
    
    /* 
     * Scales colors, not alpha value 
     */
    void scaleColors(GLfloat factor) {
       for(size_t i = 0; i < 3; ++i) {
           myColor[i] *= factor;
       } 
    }
	
	void add(GLfloat offset)
	{
		myColor[0] += offset;
		myColor[1] += offset;
		myColor[2] += offset;
	}

private:
    /* data */
};

std::ostream &operator<<(std::ostream &output, const Color4f &c) {
	cout << "Color4f(" << c[0] << ", " << c[1] << ", " << c[2] << ", " << c[3] << ')';
	return output;
}

#endif /* end of include guard: COLOR4F_H_CEDXMB57 */
